<table id="tableCustStockAlert">
    <thead class="center bold">
        <tr>
            <td ROWspan="2">&nbsp;</td>
            <td colspan="3">Num. of Products</td>
        </tr>
        <tr>
            <td><= Min</td>
            <td>< Max</td>
            <td>> Max</td>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($this->data as $data) : ?>
        <?php if ($data['0']['brand_null'] == true) : ?>
                <tr class="bold even-cell">
                    <td class="<?php echo empty($data['ROW']['supplier_name']) ? 'text-right' : ''; ?>">
                <?php
                echo $html->link(
                        empty($data['ROW']['supplier_name']) ? 'ALL' : ($data['ROW']['supplier_name'] == 'its' ? $this->requestAction('system_preferences/get/company_name') : $data['ROW']['supplier_name']),
                        '/users/popup_cust_supplier_inventories/' . 
                        (empty($data['ROW']['supplier_name']) ? '' : ($data['ROW']['supplier_name'] == 'its' ? 'dispatch_from:its' : 'dispatch_from:supplier/supplier_id:' . $data['ROW']['supplier_id'])),
                        array('onclick' => 'return false;')
                );
                ?>
            </td>
            <td class="text-right "><?php echo $data['ROW']['num_red']; ?></td>
            <td class="text-right "><?php echo $data['ROW']['num_yellow']; ?></td>
            <td class="text-right "><?php echo $data['ROW']['num_green']; ?></td>
        </tr>
        <?php elseif ($data['0']['supplier_null'] == false && $data['0']['brand_null'] == false) : ?>
                    <tr class="odd-cell">
                        <td style="text-indent: 5pt;">
                <?php
                    echo $html->link($data['ROW']['brand_name'],
                            '/users/popup_cust_supplier_inventories/brand_id:' . $data['ROW']['brand_id'] . '/dispatch_from:' . $data['ROW']['dispatch_from'],
                            array('onclick' => 'return false;'));
                ?>
                </td>
                <td class="text-right min-stock"><?php echo $data['ROW']['num_red']; ?></td>
                <td class="text-right max-stock"><?php echo $data['ROW']['num_yellow']; ?></td>
                <td class="text-right green"><?php echo $data['ROW']['num_green']; ?></td>
            </tr>
        <?php endif; ?>
        <?php endforeach; ?>
                </tbody>
            </table>
            <div class="caption">
                Number of Products that<br />
                <span class="min-stock rect"></span> Current Stock is less than or equal Min Stock.<br />
                <span class="max-stock rect"></span> Current Stock is less than Max Stock.<br />
                <span class="green rect"></span> Current Stock is higher than Max Stock.<br />
            </div>
            <script type="text/javascript">
                $j(function() {
                    $j('#tableCustStockAlert tbody tr a').popup();
                    // ดักจับ event คลิกที่แถว แล้วคลิกที่ชื่อ site ต่อให้เลย
                    $j('#tableCustStockAlert tbody tr').hightlight().handover().bind('click', function(e) {
                        if (e.target.tagName != 'A') {
                            $j('a', this).trigger('click');
                        }
                    })
                });
            </script>

<?php //debug($this->data);   ?>